# bacteria & enzyme
import pygame
from random import randint

#  bacteria
class Alien(pygame.sprite.Sprite):
    def __init__(self,color,x,y):
        super().__init__()
        file_path = '../graphics/' + color + '.png'# the files are named by color
        self.image = pygame.image.load(file_path).convert_alpha()
        self.rect = self.image.get_rect(topleft = (x,y))

        # set different scores
        if color == 'red':self.value = 30
        elif color == 'green':self.value = 20
        else:self.value = 10

    def update(self,direction):
        self.rect.x += direction

# enzyme
class Extra(pygame.sprite.Sprite):
    def __init__(self,side,screen_width,screen_height):
        super().__init__()
        self.image = pygame.image.load('../graphics/extra.png').convert_alpha()
        self.height_y_constraint = screen_height
        self.y_speed = randint(3,5)
        y = randint(30,100)

        # set the movement
        if side == 'right':
            x = screen_width + 50
            self.speed = -3
        else:
            x = -50
            self.speed = 3

        self.rect = self.image.get_rect(topleft = (x,y))

    # kill the laser when outside the screen
    def destroy(self):
        if self.rect.y <= -50 or self.rect.y >= self.height_y_constraint +50:
            self.kill()

    def update(self):
        self.rect.x += self.speed
        self.rect.y += self.y_speed